<template>
	<view class="content">
		<view style="height: 40rpx;"></view>
		<view v-if="list" class="wid85 mar">
			<view class="dis disAl disJuB mar-bott20">
				<view class="foSi30 fowe600" style="color: #D06000;">{{list.type == 2?'代放生':'代许愿'}}</view>
				<view class="foSi20" style="color: #5A5959;">{{list.createtime | formatDate}}</view>
			</view>
			<view v-if="list.fs == 0" class="foSi25 fowe600" style="">放生鱼品种：{{list.goods.name}}</view>
			<view v-if="list.fs != 0" class="foSi25 fowe600" style="">{{list.goods.name}}</view>
			<view class="dis disAl disJuB foSi25 fowe600 mar-top10">
				<view v-if="list.fs == 0" class="webkitLineClamp" style="width: 75%;">放生留言：{{list.note}}</view>
				<view v-if="list.fs != 0" class="webkitLineClamp" style="width: 75%;">许愿内容：{{list.note}}</view>
				<view class="foSi30 " style="color: #C38D5F;">¥{{list.money}}</view>
			</view>
			<view class="wid100 xia mar-top20"></view>
			<view class="foSi30 fowe600" style="margin: 30rpx 0;color: #D06000;">视频详情</view>
			<view class="wid100" style="height: 300rpx;">
				<video class="wh100 borRad10" :src="ossurl+list.wish.video" object-fit="fill"></video>
			</view>
			<view class="mar-top30 foSi25 fowe600">负责人：{{list.wish.name}}</view>
			<view class="mar-top30 foSi25 fowe600">放生时间：{{list.wish.releasetime | formatDate}}</view>
			<view class="mar-top30 foSi25 fowe600">放生地点：{{list.wish.releaseaddress}}</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				url:this.global.url,
				ossurl:this.global.ossurl,
				list: '',
				id: ''
			}
		},
		onLoad(option) {
			this.id = option.id
			this.getOrder(option.is)
			this.alioss()
		},
		methods: {
			alioss(){
				var that  = this;
				uni.request({
				    // http://jufeng.tengshuokeji.cn//yonghu/order/order_comments
				    url: that.global.url + '/api/index/alioss',
				    method: "POST",
				    data: {},
				    success(res) {
				        let result = res.data
				        console.log(result)
				        if (result.code == 1) {
				            that.global.ossurl = result.data
							console.log(that.global.ossurl);
							that.ossurl = that.global.ossurl;
				        }
				    }
				})
			},
			getOrder(is){
				var url = '/api/order/detail'
				if(is){
					url = '/api/wish/detail'
				}
				var that = this
				uni.request({
					url: that.global.url+url, 
					data: {
						id: parseInt(that.id)
					},
					header: {
						 'Content-Type': 'application/json' ,//自定义请求头信息
						 'token':uni.getStorageSync('token')
					},
					method:'POST',//请求方式，必须为大写
					success: (res) => {
					    let result = res.data
					    if(result.code == 1){
							console.log(result.data);
							that.list = result.data
					    }else{
					        uni.showToast({
					            title: result.msg,
					            icon:'none',
								duration: 2000
					        })
					    }
					}
				})
			},
			tiaozhuan(url){
				uni.navigateTo({
					url: url
				})
			},
		},
		filters: {
			formatDate(value) {
				let date = new Date(value * 1000);
				//时间戳为10位需*1000，时间戳为13位的话不需乘1000
				let y = date.getFullYear();
				let MM = date.getMonth() + 1;
				MM = MM < 10 ? ('0' + MM) : MM; //月补0
				let d = date.getDate();
				d = d < 10 ? ('0' + d) : d; //天补0
				let h = date.getHours();
				h = h < 10 ? ('0' + h) : h; //小时补0
				let m = date.getMinutes();
				m = m < 10 ? ('0' + m) : m; //分钟补0
				let s = date.getSeconds();
				s = s < 10 ? ('0' + s) : s; //秒补0
				return y + '-' + MM + '-' + d; //年月日
				// return y + '-' + MM + '-' + d + ' ' + h + ':' + m+ ':' + s; //年月日时分秒
		
			}
		}
	}
</script>

<style>
	.content {
		height: 100vh;
	}
	.xq{
		background-color: #C38D5F;
		width: 130rpx;
		height: 50rpx;
	}
	.xq1{
		border: 1rpx solid #C38D5F;
		color: #C38D5F;
		width: 130rpx;
		height: 50rpx;
	}
	.xia{
		background-color: #E5E5E5;
		height: 1rpx;
	}
</style>